﻿#include "progress.h"

Progress::Progress(QObject *parent)
    : QBaseEntity(parent)
{
    clear();
    const QMetaObject *metaObject = this->metaObject();
    setTableName(QString(metaObject->className()).toLower());
    setPrimaryKey("id");
}

Progress::~Progress()
{
}

uint64_t Progress::getId() const
{
    return id;
}

void Progress::setId(const uint64_t &value)
{
    id = value;
}

QString Progress::getPath() const
{
    return path;
}

void Progress::setPath(const QString &value)
{
    path = value;
}

QString Progress::getName() const
{
    return name;
}

void Progress::setName(const QString &value)
{
    name = value;
}

bool Progress::getVanish_up() const
{
    return vanish_up;
}

void Progress::setVanish_up(bool value)
{
    vanish_up = value;
}

bool Progress::getCpu_use_up() const
{
    return cpu_use_up;
}

void Progress::setCpu_use_up(bool value)
{
    cpu_use_up = value;
}

int Progress::getCpu_level() const
{
    return cpu_level;
}

void Progress::setCpu_level(int value)
{
    cpu_level = value;
}

bool Progress::getHeartbeat_up() const
{
    return heartbeat_up;
}

void Progress::setHeartbeat_up(bool value)
{
    heartbeat_up = value;
}

QString Progress::getHeartbeat_msg() const
{
    return heartbeat_msg;
}

void Progress::setHeartbeat_msg(const QString &value)
{
    heartbeat_msg = value;
}

bool Progress::getHeartbeat_exit() const
{
    return heartbeat_exit;
}

void Progress::setHeartbeat_exit(bool value)
{
    heartbeat_exit = value;
}

bool Progress::getInit_start() const
{
    return init_start;
}

void Progress::setInit_start(bool value)
{
    init_start = value;
}

int Progress::getStart_sleep() const
{
    return start_sleep;
}

void Progress::setStart_sleep(int value)
{
    start_sleep = value;
}

bool Progress::getDaemon_open() const
{
    return daemon_open;
}

void Progress::setDaemon_open(bool value)
{
    daemon_open = value;
}

int Progress::getHeartbeat_timeout_second() const
{
    return heartbeat_timeout_second;
}

void Progress::setHeartbeat_timeout_second(int value)
{
    heartbeat_timeout_second = value;
}

//QString Progress::generateUpdateSql() const
//{
//    QVariantMap properties = getAllProperties();
//    if (getPrimaryKey().isEmpty() || !properties.contains(getPrimaryKey())) {
//        return "";
//    }
//    QStringList updates;
//    for (auto it = properties.begin(); it != properties.end(); ++it) {
//        if (it.key() != getPrimaryKey()) {
//            if(it.key() == "createTime") continue;
//            if(it.key() == "updateTime") continue;
//            if(it.value().type() == QVariant::String){
//                updates.append(QString("`%1` = '%2'").arg(it.key()).arg(it.value().toString()));
//            }else if(it.value().type() == QVariant::StringList){
//                updates.append(QString("`%1` = '%2'").arg(it.key()).arg(it.value().toStringList().join(",")));
//            }else if(it.value().type() == QVariant::List){
//                //忽略
//            }else{
//                updates.append(QString("`%1` = %2").arg(it.key()).arg(it.value().toString()));
//            }
//        }
//    }
//    return QString("UPDATE %1 SET %2 WHERE %3 = '%4'")
//            .arg(getTableName())
//            .arg(updates.join(", "))
//            .arg(getPrimaryKey())
//            .arg(properties[getPrimaryKey()].toString());
//}
